package com.sds.shop.action;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sds.fw.mvc.Action;
import com.sds.fw.mvc.HttpUtil;
import com.sds.shop.dao.ProductDAO;
import com.sds.shop.vo.ProductVO;

public class ProductModifyAction extends Action{
	public void execute(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
		ProductVO product = new ProductVO();
		
		product.setPrdNo(request.getParameter("prd_no"));
		product.setPrdNm(request.getParameter("prd_nm"));
		product.setCategoryNo(request.getParameter("category_no"));
		product.setPrdDes(request.getParameter("prd_des"));
		product.setSellPrcUnit(Integer.parseInt(request.getParameter("sell_prc_unit")));
		product.setSellStartDt(request.getParameter("sell_start_dt"));
		product.setSellEndDt(request.getParameter("sell_end_dt"));
		product.setDlvConstraint(request.getParameter("dlv_constraint"));
		product.setAsFlg(request.getParameter("as_flg"));
		product.setReturnFlg(request.getParameter("return_flg"));
		
		product.setImgOrgFileNm(request.getParameter("img_org_file_nm"));
		product.setImgGenFileNm(null);
		product.setRegId(request.getParameter("reg_id"));
		product.setRegDtm(request.getParameter("reg_dtm"));
		
		ProductDAO.getInstance().modifyProduct(product);
				
		String param = "goodsCode=" + product.getPrdNo();
		param = param + "&categoryCode=" + product.getCategoryNo();
		param = param + "&goodsName=" + HttpUtil.encoding(product.getPrdNm());
		param = param + "&startPrice=" + product.getSellStartDt();
		param = param + "&endPrice=" + product.getSellEndDt();
		
		HttpUtil.forward(request, response, "detail.do?" + param);
	}
}